<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>隐藏文本内容</title>



</head>

<body>


    <div style="margin: 100px auto;text-align: center;">
        <input id="text" type="text">
    </div>






</body>

<script>
    var text = document.getElementById('text');
    // 获取焦点
    text.onfocus = function() {
            text.value = '';
        }
        // 失去焦点
    text.onblur = function() {
        text.value = '你好';
    }
</script>

</html>